#include <copydir.h>
//删除文件夹与文件夹里的内容
void remove_directory(char *path) {
	DIR *dir;
	struct dirent *entry;
	char ch[CH_SIZE];
	
	dir = opendir(path);
/*	if (dir == NULL) {
		perror("opendir");
		exit(-1);
	}
*/
	while ((entry = readdir(dir)) != NULL) {
		if (strcmp(entry->d_name,".") == 0||strcmp(entry->d_name,"..") == 0) 
			continue;
		sprintf(ch, "%s/%s", path, entry->d_name);
		if (entry->d_type & DT_DIR) {
			remove_directory(ch);
		} else {
			remove(ch);
		}
		
	}
	closedir(dir);
	
	remove(path);
	FILE *f = fopen("./pro_copy.log","a+");
	time_t rawtime;
	struct tm *timeinfo;
	timeinfo = localtime(&rawtime);
	fprintf(f,"\007The current date/time is:%s\n",asctime(timeinfo));
	fprintf(f,"remove %s\n",path);
	fclose(f);
}

